package com.shamar.blog.service.impl;


import com.shamar.blog.dao.BlogLabelDao;
import com.shamar.blog.dto.BlogLabelExecution;
import com.shamar.blog.entity.BlogLabel;
import com.shamar.blog.enums.BlogLabelStateEnum;
import com.shamar.blog.service.BlogLabelService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


@Service
public class BlogLabelServiceImpl implements BlogLabelService {
	@Autowired
	private BlogLabelDao BlogLabelDao;


	@Override
	public BlogLabelExecution getBlogLabelListByCount( int pageIndex,
                                             int pageSize) {
		//将pageindex转换为rowindex
//		int rowIndex = PageCalculator.calculateRowIndex(pageIndex, pageSize);
		//根据BlogLabelCondition查找BlogLabelList
//        if (pageIndex == null){
//            pageIndex = 1;
//        }
		List<BlogLabel> blogLabelList = BlogLabelDao.getBlogLabelList(pageIndex,pageSize);
		BlogLabelExecution be = new BlogLabelExecution();
		if (blogLabelList != null){
			be.setBlogLabelList(blogLabelList);
			be.setState(BlogLabelStateEnum.NORMAL.getState());
			return be;
		}
		be.setState(BlogLabelStateEnum.EMPTY_RESULT.getState());
		be.setStateInfo(BlogLabelStateEnum.EMPTY_RESULT.getStateInfo());
		return be;
	}




}
